// pages/auth/index.js
import { request } from '../../request/index.js'
import regeneratorRuntime from '../../lib/runtime/runtime';
Page({
  data: {
    code: ''
  },
  onLoad: function (options) {

  },
  handelBindgetuserinfo(e) {
    // 获取用户信息
    const { encryptedData, rawData, iv, signature } = e.detail
    // 获取登录成功后的code
    // let code = ''
    wx.login({
      timeout: 10000,
      success: (result) => {
        const {code} = result
        const loginParams = { encryptedData, rawData, iv, signature, code }
        request({ url: "/users/wxlogin", data: loginParams, method: "post" })
        .then((res)=>{
          // 将模仿的tokn存入缓存
          wx.setStorageSync('token', 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjIzLCJpYXQiOjE1NjQ3MzAwNzksImV4cCI6MTAwMTU2NDczMDA3OH0.YPt-XeLnjV-_1ITaXGY2FhxmCe4NvXuRnRB8OMCfnPo');
          wx.navigateTo({
            url: '../pay/index',
          });
            
        })
      },
    });
  }
})